import React from "react";
// import {connect} from "react-redux";
import {LOGIN,} from "../const/locations";
import ProgressView from "../view/ProgressView";
import {getTOKEN} from "../utils/StorageUtil";
import {getParam, locationReplace, locationTo} from "../utils/LocationUtil";
import {isStrEmpty} from "../utils/CommomUtil";
// import {createMapState, createDispatchState} from "../utils/MemberStepUtil";
import * as locations from "../const/locations";
// import Config from "../Config";

/**
 * 进入应用时页面。
 * 根据用户状态显示不同的页面。如：用户还未进行认证，跳转到认证页面；用户未登录跳转到登录页面
 */
class EnterScreen extends React.Component {
    componentWillMount() {
        if (getParam("location")) {
            this.setState({
                info: "正在加载"
            });
        }
        if (getParam("ps")) {
            this.setState({
                info: "正在更新状态"
            });
        }
    }
    componentDidMount() {        
        this.verify();
    }

    componentWillReceiveProps(nextProps) {
      
    }

    constructor(props) {
        super(props);
        document.title = "加载中...";
        this.state = {
            info: "即将进入系统"
        };
        locationTo(locations.MAIN)  
    }

    render() {
        return (
            <div style={EnterStyle.container}>
                <div style={{textAlign: "center"}}>
                    <ProgressView visibility={true}/>
                    <p>{this.state.info}</p>
                </div>
            </div>
        );
    }

    /******************业务逻辑处理***********************/

    verify() {
        //id验证
        let TOKEN = getTOKEN();
        if (isStrEmpty(TOKEN)) {
            locationReplace(LOGIN);
            return;
        }
        //根据用户状态跳转指定位置        
    }

    // dealLocation() {
    //     let location = getParam("location");
    //     if (location) {
    //         locationReplace(location);
    //         return true;
    //     }
    // }

}

const EnterStyle = {
    container: {
        display: "flex",
        flex: 1,
        flexDirection: "column",
        justifyContent: "center",
        alignItems: "center",
        minHeight: "100vh"
    }
};

// export default connect(createMapState(), createDispatchState())(EnterScreen);
export default EnterScreen;
